package java_thinking.unit_15._15_15;

import java.awt.*;
import java.util.Random;

/**
 * @Description :   混型
 *                  与接口混合
 * @author: cww
 * @DateTime: 2019-04-07 18:31
 */
interface Colored { Color getColor(); }

class ColoredImp implements Colored {
    private static Random rnd = new Random(47);
    private final Color clr = new Color(rnd.nextInt(16777216));
    @Override
    public Color getColor() { return clr; }
}
public class Mixin2 extends Mixin implements Colored {
    private Colored colored = new ColoredImp();
    @Override
    public Color getColor() { return colored.getColor(); }
}
class E37_Mixins2 {
    public static void main(String[] args) {
        Mixin2 mixin1 = new Mixin2(), mixin2 = new Mixin2();
        mixin1.set("test string 1");
        mixin2.set("test string 2");
        System.out.println(mixin1.get() + " " +
                mixin1.getStamp() +  " " +
                mixin1.getSerialNumber() + " " + mixin1.getColor());
        System.out.println(mixin2.get() + " " +
                mixin2.getStamp() +  " " +
                mixin2.getSerialNumber() + " " + mixin2.getColor());
    }
}